//
//  ImageCell.m
//  UI12 Cell自适应高度
//
//  Created by 郑一楠 on 15/9/1.
//  Copyright (c) 2015年 Riven. All rights reserved.
//

#import "ImageCell.h"

@interface ImageCell ()

@property (nonatomic, retain) UIImageView *titleImageView;

@end

@implementation ImageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titleImageView = [[UIImageView alloc] init];
        self.titleImageView.backgroundColor = [UIColor colorWithRed:0.52 green:0.22 blue:0.3 alpha:1];
        [self.contentView addSubview:self.titleImageView];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.titleImageView.frame = self.contentView.frame;
}
/*
- (void)setModel:(Model *)model {
    self.titleImageView.image = [UIImage imageNamed:model.imageName];
}
*/
+ (CGFloat)heightForCellWithImage:(NSString *)imageName {
    //创建image对象
    UIImage *image = [UIImage imageNamed:imageName];
    
    //根据image的size属性，计算新的高度
    CGFloat h = 375 * image.size.height / image.size.width;
    
    //返回高度
    return h;
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
